{% extends '/pg/index.html' %}
{% block operation %}
<ul class="breadcrumb">
  <li><a href="/pg">Home</a></li>
  <li><a href="/pg/parametri">Parametri</a></li>
  <li class="active">Anagrafica Categorie</li>
</ul>
<h2 class="text-center">Categorie</h2>

{% include "pg/btn_action.html" with context %}
<button type="button" id="ordina" class="btn btn-danger">Ordina</button>

{% include "pg/filterkey/fk_rilevazioni.html" with context %}

{%endblock%}

{% block custom_js %}
<script type="text/javascript">
$(document).ready(function () {

$(".Preview").hide()
$("#anteprima").hide()
$(".Edit_dao").hide()
$("#edit_dao").hide()
$("#print_dao").hide()

$('#tableContainer_ac').jtable({
    title: 'Tabella Categorie',
    messages: window.italianMessages,
    paging: true,
    pageSize: 20,
    sorting: true,
    defaultSorting: 'ordine ASC',
    selecting: true,
    create:false,

    actions: {
        listAction: '/pg/ac_Categoria/List',
        deleteAction: '/pg/ac_Categoria/Delete'
    },
    fields: {
        id: {
            key: true, create: false, edit: false, list: false },
        icona_categoria: {
            title: 'icona',
            width: '2%',
            display: function (data) {
                var $img = $("<img src='data:image/png;base64,"+ data.record.icona_categoria +"' width='16' height='16'/>");
                return $img;
                }
        },
        denominazione: {
            title: 'Denominazione',
            width: '38%',
        },
        denominazione_breve: {
            title: 'Denominazione Breve',
            width: '14%',
        },
        id_tipo_categoria: {
            title: 'Tipo Categoria',
            width: '10%',
            options: '/pg/ac_Categoria/GetTipoCategoria',
            display: function (data) {
                return data.record.catalogo;
                }
        },
        id_tipo_geo: {
            title: 'Tipo Geo',
            width: '11%',
            options: '/pg/ac_Categoria/GetTipoGeo',
        },
        foto: {width: '8%',title: 'Foto',type: "checkbox", values: { 'false': 'Non Foto', 'true': 'Foto' },defaultValue: 'false',},

    },
    selectionChanged: function () {
    //Get all selected rows

    var $selectedRows = $('#tableContainer_ac').jtable('selectedRows');
    $("#anteprima").hide();
    $('.Preview').empty();
    $("#print_dao").hide();
    $("#edit_dao").hide();

    if ($selectedRows.length > 0) {
        //Show selected rows
        $("#edit_dao").show()
        $("#anteprima").show()
        //$("#print_dao").show()

    }
},
});

filtra = function() {
    $('#tableContainer_ac').jtable('load', {
        fk_denominazione: $('#fk_denominazione').val(),
        });
    }



$('#tableContainer_ac').jtable('load');
$('#anteprima').attr('preview', '/pg/ac_Categoria/Preview');
$('#new_dao').attr('nuovo_dao', '/pg/ac_Categoria/Edit');
$('#edit_dao').attr('modifica_dao', '/pg/ac_Categoria/Edit');
$('#ordina').attr('ordinaa', '/pg/ac_Categoria/Ordina');

});
</script>
{% endblock %}
